/*
 * OpenParts
 * A dynamic-loading components framework for GWT
 * Copyright (C) 2011 Christophe Bouthier  [chris{AT}binary-gastronome{DOT}fr]
 *
 * This work is partially based on work I have done at INRIA (http://www.inria.fr) 
 * in the context of the Qualipso European Project (http://qualipso.org/),
 * The work done at INRIA is Copyright (C) 2006-2011 INRIA
 *
 * This work is distributed under the LGPL version 3
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License version 3
 * as published by the Free Software Foundation. See the GNU
 * Lesser General Public License in LGPL.txt for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package fr.openparts.OpenParts.rebind;

import com.google.gwt.core.ext.typeinfo.JMethod;

/**
 * Manage data for view factory.
 * 
 * @author Christophe Bouthier [chris{AT}binary-gastronome{DOT}fr]
 * @creation.date 29 December 2009
 */
public class OPBinderBuildingDataViewFactory {

    /**
     * The view factory.
     */
    protected final JMethod factory;

    /**
     * The name of the service represented by this view.
     */
    protected final String serviceName;

    /**
     * The name of the resource represented by this view.
     */
    protected final String resourceName;

    /**
     * The name of the action represented by this view.
     */
    protected final String actionName;
    
    /**
     * The mandatory parameters of this view. Can be empty, but cannot be null.
     */
    protected final String[] mandatoryParams;

    /**
     * Constructor. Takes the factory, its resource and action names, and if necessary its mandatory parameters.
     * 
     * @param factory
     *            the view factory. Shouldn't be null.
     * @param serviceName
     *            the name of the service represented by this view. Shouldn't be null.
     * @param resourceName
     *            the name of the resource represented by this view. Shouldn't be null.
     * @param actionName
     *            the name of the action represented by this view. Shouldn't be null.
     * @param mandatoryParams
     *            the mandatory parameters names. Can be empty, but shouldn't be null.
     */
    public OPBinderBuildingDataViewFactory(final JMethod factory, final String serviceName, final String resourceName, final String actionName,
            final String... mandatoryParams) {

        assert factory != null : "parameter factory shouldn't be null";
        assert serviceName != null : "parameter serviceName shouldn't be null";
        assert resourceName != null : "parameter resourceName shouldn't be null";
        assert actionName != null : "parameter actionName shouldn't be null";
        assert mandatoryParams != null : "parameter mandatoryParams shouldn't be null";

        this.factory = factory;
        this.serviceName = serviceName;
        this.resourceName = resourceName;
        this.actionName = actionName;
        this.mandatoryParams = mandatoryParams;
    }

    /**
     * Return the view factory.
     * 
     * @return the view factory. Cannot be null.
     */
    public JMethod getFactory() {
        return factory;
    }

    /**
     * Return the name of the service represented by this view.
     * 
     * @return the name of the service represented by this view. Cannot be null.
     */
    public String getServiceName() {
        return serviceName;
    }

    /**
     * Return the name of the resource represented by this view.
     * 
     * @return the name of the resource represented by this view. Cannot be null.
     */
    public String getResourceName() {
        return resourceName;
    }

    /**
     * Return the name of the action represented by this view.
     * 
     * @return the name of the action represented by this view. Cannot be null.
     */
    public String getActionName() {
        return actionName;
    }
    
    /**
     * Return the mandatory parameters of this view.
     * 
     * @return the mandatory parameters of this view. Can be empty, but cannot be null.
     */
    public String[] getMandatoryParams() {
        return mandatoryParams;
    }
}
